﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DamageCalculator.Classes
{
    public class Encounter
    {
        long mEncounterID;
        DateTime mStartTime;
        DateTime mEndTime;
        List<Entry> mEntries;
        bool misOpen;
        String mName;

        public Encounter(long pEncounterID)
        {
            this.mEncounterID = pEncounterID;
            this.mEntries = new List<Entry>();
            this.misOpen = true;
        }

        public Encounter(long pEncounterID, DateTime pStartTime)
            : this(pEncounterID)
        {
            this.mStartTime = pStartTime;
        }

        public String Name
        {
            get { return this.mName; }
            set { this.mName = value; }
        }

        public bool isOpen
        {
            get { return this.misOpen; }
            set { this.misOpen = value; }
        }

        public long EncounterID
        {
            get { return this.mEncounterID; }
        }

        public DateTime StartTime
        {
            get { return this.mStartTime; }
            set { this.mStartTime = value; }
        }

        public DateTime EndTime
        {
            get { return this.mEndTime; }
            set { this.mEndTime = value; }
        }

        public List<Entry> Entries
        {
            get { return this.mEntries; }
        }

        public int LengthInSeconds
        {
            get
            {
                if (this.mEndTime != new DateTime())
                {
                    return (int)(this.mEndTime - this.mStartTime).TotalSeconds;
                }
                else
                    return (int)(DateTime.Now - this.mStartTime).TotalSeconds;
            }
        }

        public override string ToString()
        {
            if (String.IsNullOrEmpty(this.mName))
                return this.StartTime.ToString();

            else
                return this.StartTime.ToString() + " " + this.mName;
        }
    }
}
